<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
  <title>Document</title>
  <style>
    #myDiv {
      width: 100px;
      height: 100px;
      background-color: blue;
    }
    #myDiv1 {
      width: 100px;
      height: 100px;
      background-color: red;
    }
  </style>
</head>
<body>
  <div id="myDiv">
    事件冒泡
  </div>
  <div id="myDiv1">
    事件捕获
  </div>
  <p>事件委托</p>
  <ul class="wt">
    <li>1</li>
    <li>21</li>
    <li>3</li>
    <li>4</li>
  </ul>
  <script>
    var div = document.getElementById('myDiv')
    div.onclick = function(event) {
      alert('div')
    }
    // document.body.onclick = function(event) {
    //   alert('body')
    // }
    // 事件捕获
    var div1 = document.getElementById('myDiv1')
    div1.addEventListener('click', function() {
      alert('div')
    }, true)
    // addEventListener第三个参数设置为true的时候，表示优先事件捕获

    // document.body.addEventListener('click', function() {
    //   alert('body')
    // }, true)

    $('.wt').on('click', function() {
      console.log('1111')
    })
  </script>
</body>
</html>